<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<style>
			.box {
				width: 200px;
				height: 200px;
				background-color: orange;
				box-sizing: border-box;

				/* box-sizing: 在生效时,有一个前提, 需要明确设置width或height */
				border: 20px solid #f00;
			}

			.container {
				margin-top: 40px;
				width: 300px;
				height: 300px;
				background-color: orange;
			}

			.box1 {
				height: 200px;
				/* width: 100%; */
				background-color: #f00;
				border-right: 40px solid #00f;
			}

			.container2 {
				width: 300px;
				height: 300px;
				background-color: #0f0;
				position: relative;
			}
			.container2 > .box2 {
				position: absolute;
				/* width: 100px;
				height: 100px; */
				background-color: #f00;
				left: 0;
				right: 0;
				bottom: 0;
				top: 0;
				border: 10px solid #00f;
				/* 没有设置width或height, box-sizing没有效果 */
				box-sizing: border-box;
				/* margin: auto; */
			}

			.container3 {
				width: 300px;
				height: 300px;
				background-color: #0f0;
				display: flex;
			}
			.container3 .box3 {
				width: 100px;
				background-color: #f00;
				border-top: 30px solid #0ff;
			}
			.container3 .box4 {
				/* flex: 1 -> flex-grow: 1 */
				flex: 1;
				background-color: purple;
				border: 30px solid skyblue;
			}
		</style>
	</head>
	<body>
		<!-- 1. 需要添加box-sizing的地方 -->
		<div class="box"></div>

		<!-- 2. 不需要添加box-sizing的地方 -->
		<div class="container">
			<div class="box1"></div>
		</div>

		<!-- 定位元素 -->
		<div class="container2">
			<div class="box2"></div>
		</div>

		<div class="container3">
			<div class="box3"></div>
			<div class="box4"></div>
		</div>
	</body>
</html>
